# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=x3270
_pkgname=suite3270
pkgver=4.3ga9
pkgrel=1
epoch=2
pkgdesc='An IBM 3270 terminal emulator for the X Window System.'
arch=('x86_64' 'aarch64')
url='http://x3270.bgp.nu/'
license=('BSD' 'MIT')
depends=('openssl' 'libxaw')
makedepends=('imake' 'openssl' 'libx11' 'libxaw' 'libxt' 'xbitmaps'
             'xorg-mkfontdir' 'xorg-bdftopcf' 'tcl')
backup=('etc/x3270/ibm_hosts')
source=("https://downloads.sourceforge.net/project/x3270/x3270/$pkgver/suite3270-$pkgver-src.tgz")
sha512sums=('bed08bbf3077cae379ce7f6e6a1a539740fc8631e81d55eda4516f07b933753b6649ad479c222c64ad86566ed4f7657c8a714bd9be361018a1b968a55b383ca8')
install="$pkgname.install"

build() {
  cd "$_pkgname-${pkgver:0:3}"

  if [[ "$CARCH" == "aarch64" ]]; then
    ./configure --prefix=/usr --bindir=/usr/bin --sbindir=/usr/bin \
      --sysconfdir=/etc --with-fontdir=/usr/share/fonts/3270 --build=arm
  else
    ./configure --prefix=/usr --bindir=/usr/bin --sbindir=/usr/bin \
      --sysconfdir=/etc --with-fontdir=/usr/share/fonts/3270
  fi

  make
}

package() {
  cd "$_pkgname-${pkgver:0:3}"

  install -dm 755 "$pkgdir/usr/share/fonts/3270/fonts.dir"

  make DESTDIR="$pkgdir" install

  install -Dm 644 x3270/x3270-icon2.xpm \
    "$pkgdir/usr/share/pixmaps/x3270-icon2.xpm"
  #install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  #chmod 644 "$pkgdir/etc/x3270/ibm_hosts"
}

